package com.heima.comment.controller;

import com.heima.comment.dto.CommentDto;
import com.heima.comment.dto.CommentLikeDto;
import com.heima.comment.dto.CommentSaveDto;
import com.heima.comment.service.IApCommentService;
import com.heima.common.dto.ResponseResult;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @description:
 * @author: CommentController
 * @time: 2022/7/4
 */
@RestController
@RequestMapping("/api/v1/comment")
public class CommentController {

    @Autowired
    private IApCommentService commentService;

    /**
     * 发表评论
     * @param dto
     * @return
     */
    @PostMapping("/save")
    @ApiOperation(value = "saveComment" ,notes = "发表评论")
    @ApiModelProperty(name = "dto" ,dataType = "CommentSaveDto" ,required = true)
    public ResponseResult saveComment(@RequestBody CommentSaveDto dto) {
        return commentService.saveComment(dto);
    }

    /**
     * 加载评论列表
     * @param dto
     * @return
     */
    @PostMapping("/load")
    @ApiOperation(value = "load" ,notes = "加载评论列表")
    @ApiModelProperty(name = "dto" ,dataType = "CommentDto" ,required = true)
    public ResponseResult load(@RequestBody CommentDto dto) {
        return commentService.load(dto);
    }

    /**
     * 点赞某一条评论
     * @param dto
     * @return
     */
    @PostMapping("/like")
    @ApiOperation(value = "like" ,notes = "点赞某一条评论")
    @ApiModelProperty(name = "dto" ,dataType = "CommentLikeDto" ,required = true)
    public ResponseResult like(@RequestBody CommentLikeDto dto){
        return commentService.like(dto);
    }
}
